﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace Company.Portal
{
    public class DataListAdapter
    {
        public static Dictionary<string, object> GetPropertyValueOfInstance(List<object> items)
       {
          Dictionary<string ,object > dictionary=new Dictionary<string, object>();
          foreach (object item in items)
          {
              var properties = item.GetType().GetProperties();
              foreach (PropertyInfo propertyInfo in properties)
                  dictionary.Add(propertyInfo.Name,
                                 item.GetType().InvokeMember(propertyInfo.Name, BindingFlags.GetProperty, null, item,
                                                             null));
          }

          
          
          return dictionary;
       }

        public static Dictionary<string,Type > GetProperties(object item)
        {
          var properties=  item.GetType().GetProperties();
            Dictionary<string,Type> propertyInfos=new Dictionary<string, Type>();
            foreach (PropertyInfo property in properties)
                propertyInfos.Add(property.Name,property.PropertyType);
            return propertyInfos;
        }
    }
}
